<?php
/**
 * 物品模板
 * 
 * Created	: 2010-11-05
 * Modified : 2010-11-05
 * @author  : 陈立强
 */
class Titem {
	
	public static $tbl = 'template_items';
	
	public static function init()
	{
		
	}
	
	/**
	 * 获取指定物品的模板数据
	 * @param int $ti_id
	 */
	public static function getInfo($ti_id)
	{
		// 获取物品模板信息
		$tiList = C('item/titem');
		return $tiList[$ti_id];
	}
	
	/**
	 * 根据物品标志获取模板数据
	 * @param int $ti_sign
	 */
	public static function getInfoBySign($ti_sign)
	{
		// 获取物品模板信息
		$tiList = C('item/titem_sign');
		return $tiList[$ti_sign];
	}
	
	/**
	 * 获取所有物品列表
	 */
	public static function getList()
	{
		// 获取物品模板信息
		$tiList = C('item/titem');
		return $tiList;
	}
	
	/**
	 * 缓存物品表模板数据
	 */
	public static function cache()
	{
		global $DB, $L, $G;
		
		$order = 'ti_id asc';
		$sql   = 'SELECT * FROM '.self::$tbl.' order by ti_id asc';
		$list  = $DB->getList($sql);
		
		$tiList = array();
		$tiSignList = array();
		$tiTypeSignList = array();
		
		foreach ($list as $v) {
			$tiList[$v['ti_id']] = $v;
			$tiSignList[$v['sign']] = $v;
			$tiTypeSignList[$v['type_sign']][] = $v;
		}

		
		UC('item/titem', $tiList);
		UC('item/titem_sign', $tiSignList);
		UC('item/titem_type_sign', $tiTypeSignList);
		
		return true;
	}
}










